const path = require('path');

//html-webpack-plugin
const HtmlWebpackPlugin = require('html-webpack-plugin');
const wmp = require('webpack-manifest-plugin');

module.exports = {
    entry: path.resolve(__dirname, '../client/app.js'),
    output: {
        filename: '[name].[chunkHash:5].js',
        path: path.resolve(__dirname, '../dist'),
        publicPath: ''
    },
    module: {
        rules: [
            {
                test: /(\.jsx|js)$/,
                exclude: /node_modules/,
                use: [
                    {
                        loader: 'babel-loader'
                    }
                ]
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            // 指定打包模板
            // 抽离出来的chunk entry 以及打包出来的css全部注入到这个模板中来
            // name就默认是他们生成出来的name
            template: path.resolve(__dirname, '../index.html'),
        }),
        // 生成打包地图给SSR加载用
        new wmp({

        })
    ]
};